package net.da.services.spi.local;

import java.util.GregorianCalendar;

import com.google.inject.Inject;

import net.da.core.bof.Acl;
import net.da.core.bof.ApplicationSession;
import net.da.core.bof.BusinessObject;
import net.da.core.bof.spi.local.BusinessObjectImpl;
import net.da.core.manager.BusinessObjectManager;
import net.da.core.manager.BusinessObjectManagerProvider;

public class BusinessObjectCreator {

    @Inject
    private BusinessObjectManager businessObjectManager;

    public static void createNewBusinessObject(BusinessObject businessObject, ApplicationSession session) {
        businessObject.setArchived(false);
        businessObject.setHidden(false);
        businessObject.setImmutable(false);

        BusinessObjectImpl internal = (BusinessObjectImpl) businessObject;
        internal.setCreationDate(GregorianCalendar.getInstance());
        internal.setCreator(session.getUser());
        internal.setLocked(false);

        internal.setOwner(session.getUser());

//        Acl acl = businessObjectManager.createBusinessObjectEmptyInstance(Acl.class);
//        ((AclImpl)acl).set();
//        acl.grant(session.getUser(), Operation.DF_PERMIT_DELETE);
//        internal.setAcl(acl);
    }
}
